package com.myapp.struts.action;

import com.myapp.hibernate.model.Entrada;
import com.myapp.hibernate.util.EntradaUtil;
import com.myapp.struts.form.EntradasForm;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

public class BorrarEntradaAction extends org.apache.struts.action.Action {

    private static final String SUCCESS = "success";

    @Override
    public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)
            throws Exception {
        EntradasForm formulario = (EntradasForm) form;
        EntradaUtil entradaUtil = new EntradaUtil();
        
        Entrada e = entradaUtil.obtenerEntrada(formulario.getIdEntrada());
        entradaUtil.borrar(e);
        return mapping.findForward(SUCCESS);
    }
}
